/**
 * Created by ospip on 2018/9/26.
 * Copyright (c) 2018 LLAP. All rights reserved.
 */
public class ChartFactory {
    public static Chart createChart(String type)
        throws UnsupportedChartException {
        String t = type.charAt(0) + "";
        if (t.equalsIgnoreCase("p")) {
            return new PieChart();
        }
        else if (t.equalsIgnoreCase("l")) {
            return new LineChart();
        }
        else if (t.equalsIgnoreCase("h")) {
            return new HistogramChart();
        }
        else {
            throw new UnsupportedChartException("Unsupported chart type: " + type);
        }
    }
}
